#!/usr/bin/env python
# -*- coding: utf-8 -*-

import matplotlib.pyplot as plt
import numpy as np

def indegree():
#     plt.figure(figsize=(30,5))
    indegree = []
    frequency = []
    in_degree_file = '/home/ivy/git/Social/Social/resource/in_degree/in_degree.txt'
    with open(in_degree_file, 'r+') as infile:
        for line in infile:
            arr = line.split('\t')
            indegree.append(np.log10(int(arr[0])))
            frequency.append(np.log10(int(arr[1])))
    
    plt.axis([0, 8, 0, 3])
    plt.plot(indegree, frequency, 'ro')
    plt.title('Log-Log Indegree Distribution')
    plt.xlabel('Indegree (10^x)')
    plt.ylabel('Count (10^y)')
    plt.show()

def outdegree():
    outdegree = []
    frequency = []
    out_degree_file = '/home/ivy/git/Social/Social/resource/out_degree/out_degree.txt'
    with open(out_degree_file, 'r+') as outfile:
        for line in outfile:
            arr = line.split('\t')
            outdegree.append(np.log10(int(arr[0])))
            frequency.append(np.log10(int(arr[1])))
    
    plt.axis([0, 7, 0, 1.5])
    plt.plot(outdegree, frequency, 'ro')
    plt.title('Log-Log Outdegree Distribution')
    plt.xlabel('Outdegree (10^x)')
    plt.ylabel('Count (10^y)')
    
    plt.show()

def main():
#     indegree()
    outdegree()
    
if __name__ == '__main__':
    main() 